// @/api/customerService.js
import request from '@/utils/request'

export const fetchChatHistory = async () => {
  try {
    const response = await request.get(`/customerService/getChatHistory`);
    return response;
  } catch (error) {
    console.error('获取聊天历史失败:', error);
    throw error;
  }
};

export const sendMessage = async (conversationId, content) => {
  try {
    const response = await request.post('/customerService/sendMessage', { conversationId, content });
    return response;
  } catch (error) {
    if (error.response && error.response.data) {
      throw new Error(error.response.data.message || '发送消息失败');
    }
    throw error;
  }
};